package wiki.hitime.stl.daq;

import com.alibaba.druid.filter.logging.Slf4jLogFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
import tk.mybatis.spring.annotation.MapperScan;

/**
 * @author zhangdaoping
 */
@Slf4j
@SpringBootApplication
@MapperScan(basePackages = {"wiki.hitime.stl.daq.mapper"})
@EnableFeignClients
@EnableScheduling
public class StlDaqApplication {

    public static void main(String[] args) {
        SpringApplication.run(StlDaqApplication.class, args);
    }

    @Bean
    public CommonsRequestLoggingFilter requestLoggingFilter() {
        CommonsRequestLoggingFilter loggingFilter = new CommonsRequestLoggingFilter();
        loggingFilter.setIncludeClientInfo(true);
        loggingFilter.setIncludePayload(true);
        loggingFilter.setMaxPayloadLength(1000);
        return loggingFilter;
    }

    @Bean("dbLogFilter")
    public Slf4jLogFilter logFilter() {
        Slf4jLogFilter filter = new Slf4jLogFilter();
        filter.setResultSetLogEnabled(true);
        filter.setConnectionLogEnabled(false);
        filter.setStatementParameterClearLogEnable(false);
        filter.setStatementCreateAfterLogEnabled(false);
        filter.setStatementCloseAfterLogEnabled(false);
        filter.setStatementParameterSetLogEnabled(false);
        filter.setStatementPrepareAfterLogEnabled(false);
        filter.setStatementExecutableSqlLogEnable(true);
        return filter;
    }
}
